class Solution(object):
    def isOneEditDistance(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        def judge_1(s, t):
            count = 0
            for i in range(len(s)):
                if s[i] != t[i]:
                    count += 1
                    if count >= 2:
                        return False
            if count == 0:
                return False
            else:
                return True

        def judge_2(s, t):
            i = 0
            j = 0
            count = 0
            while i < len(s) and j < len(t):
                if s[i] == t[j]:
                    i += 1
                    j += 1
                else:
                    count += 1
                    i += 1
                    if count >= 2:
                        return False
            return True

        if abs(len(s) - len(t)) >= 2:
            return False
        else:
            if len(s) == len(t):
                return judge_1(s, t)
            else:
                if len(s) > len(t):
                    return judge_2(s, t)
                else:
                    return judge_2(t, s)


data = Solution()
s = "ab"
t = "dcb"
print(data.isOneEditDistance(s, t))
